package com.anycl.design.behavioral.visitor.instance;

import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class NormalVisitor implements Visitor {
    private List<String> perms;

    public NormalVisitor(List<String> perms) {
        this.perms = perms;
    }

    @Override
    public void visit(FileElement element) {
        if (this.perms.indexOf(element.getPerms() )>= 0) {
            log.info("当前：普通用户 要访问的文件名: " + element.getName() + "，权限：" + element.getPerms());
        } else {
            log.info("当前：普通用户 要访问的文件名: " + element.getName() + "，权限不足，禁止访问" );
        }
    }

    @Override
    public void visit(FolderElement element) {
        if (this.perms.indexOf(element.getPerms() )>= 0) {
            log.info("当前：普通用户 要访问的文件夹名: " + element.getName() + "，权限：" + element.getPerms());
        } else {
            log.info("当前：普通用户 要访问的文件夹名: " + element.getName() + "，权限不足，禁止访问" );
        }
    }
}
